package mo.tags.stack;

import java.util.Stack;

public class L155 {

    private Stack<Integer> data = new Stack<>();
    private Stack<Integer> min = new Stack<>();

    public L155() {

    }

    public void push(int val) {
        data.push(val);
        if (min.isEmpty()) {
            min.push(val);
        } else {
            min.push(Math.min(min.peek(), val));
        }
    }

    public void pop() {
        data.pop();
        min.pop();
    }

    public int top() {
        return data.peek();
    }

    public int getMin() {
        return min.peek();
    }

}
